/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.CommentDAO;
import com.sesame.domain.Comment;

/**
 * @author voidman
 * 
 */
public class CommentDAOImpl extends SqlMapClientDaoSupport implements
        CommentDAO {

    public void addComment(Comment comment) {
        getSqlMapClientTemplate().insert("addComment", comment);
    }

    public void deleteCommentById(Integer id) {
        getSqlMapClientTemplate().delete("deleteCommentById", id);
    }

    @SuppressWarnings("unchecked")
    public List<Comment> getAllComment() {
        return (List<Comment>) getSqlMapClientTemplate().queryForList(
                "getAllComment");
    }

    public List<Comment> getCommentByImageId(Integer imageId) {
        return (List<Comment>) getSqlMapClientTemplate().queryForList(
                "getCommentByImageId", imageId);
    }

    public Comment getCommentById(Integer id) {
        return (Comment) getSqlMapClientTemplate().queryForObject(
                "getCommentById", id);
    }

    public void updateComment(Comment comment) {
        getSqlMapClientTemplate().update("updateComment", comment);
    }

}